﻿@page "/system_manager/function"
<div>
    <PageContainer Title="">
        <Breadcrumb>
            <Breadcrumb>
                <BreadcrumbItem>系统管理</BreadcrumbItem>
                <BreadcrumbItem>功能管理</BreadcrumbItem>
            </Breadcrumb>
        </Breadcrumb>
        <ChildContent>
            <Table @ref="_table"
                   TItem="FunctionDto"
                   DataSource="@_datas"
                   Total="_total"
                   OnChange="@OnChange"
                   @bind-PageIndex="searchInput.PageIndex"
                   @bind-PageSize="searchInput.PageSize"
                   @bind-SelectedRows="_selectedRows"
                   Loading="@_tableIsLoading"
                   Context="model">
                <TitleTemplate>
                    <Row>
                        <AntDesign.Col Span="8">
                            <ResourceAuthorize ResourceKey="system_manager_function_delete_selected">
                                <Button Type="@ButtonType.Primary" Icon="delete" Danger OnClick="OnDeletesClick" Loading="onDeletesLoading">
                                    删除选中
                                </Button>
                            </ResourceAuthorize>
                        </AntDesign.Col>
                        <AntDesign.Col Span="16" Style="text-align:right">
                            <Space>
                                <ResourceAuthorize ResourceKey="system_manager_function_import">
                                    <SpaceItem>
                                        <Button Type="@ButtonType.Primary" Icon="import" OnClick="OnImportClick">
                                            导入
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                                @*<ResourceAuthorize ResourceKey="system_manager_function_add">
                                        <SpaceItem>
                                            <Button Type="@ButtonType.Primary" Icon="plus" OnClick="OnAddClick">
                                                添加
                                            </Button>
                                        </SpaceItem>
                                    </ResourceAuthorize>*@

                                <ResourceAuthorize ResourceKey="system_manager_function_refresh">
                                    <SpaceItem>
                                        <Button Type="@ButtonType.Primary" Icon="reload" OnClick="OnReLoadTable">
                                            刷新
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                                <ResourceAuthorize ResourceKey="system_manager_function_download_seed_data">
                                    <SpaceItem>
                                        <Button Type="@ButtonType.Primary" Icon="download" OnClick="OnDownloadClick">
                                            种子数据
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                            </Space>
                        </AntDesign.Col>
                    </Row>

                </TitleTemplate>
                <RowTemplate>
                    <ResourceAuthorize ResourceKey="system_manager_function_delete_selected">
                        <Selection Key="@(model.Id.ToString())" Width="5%" />
                    </ResourceAuthorize>
                    <Column @bind-Field="@model.Group" Width="10%" />
                    <Column @bind-Field="@model.Service" Width="10%" />
                    <Column @bind-Field="@model.Summary" Width="10%" />
                    <Column @bind-Field="@model.Path" Width="60" />
                    <Column @bind-Field="@model.Method" Width="10%" Filters="TableFiltersConstants.FunctionMethodFilters">
                        <TagRandomColor Text="@EnumExtension.GetEnumDescription(model.Method)"></TagRandomColor>
                    </Column>
                    <Column @bind-Field="@model.EnableAudit" Width="8%">
                        <ResourceAuthorize ResourceKey="system_manager_function_enable_audit">
                            <Authorized>
                                <Switch @bind-Value="@model.EnableAudit" OnChange="e=>OnChangeEnableAudit(model,e)"></Switch>
                            </Authorized>
                            <NotAuthorized>
                                <TagYesNo Yes="model.EnableAudit"></TagYesNo>
                            </NotAuthorized>
                        </ResourceAuthorize>
                    </Column>
                    <Column @bind-Field="@model.IsLocked" Width="8%">
                        <ResourceAuthorize ResourceKey="system_manager_function_lock">
                            <Authorized>
                                <Switch @bind-Value="@model.IsLocked" OnChange="e=>OnChangeIsLocked(model,e)"></Switch>
                            </Authorized>
                            <NotAuthorized>
                                <TagYesNo Yes="model.IsLocked"></TagYesNo>
                            </NotAuthorized>
                        </ResourceAuthorize>
                    </Column>
                    <Column @bind-Field="@model.CreatedTime" Format="@ClientConstant.DateTimeFormat" Sortable Width="10%" />
                    <ActionColumn Width="10%">
                        <Space>
                            <ResourceAuthorize ResourceKey="system_manager_function_edit">
                                <SpaceItem>
                                    <Tooltip Title="@("编辑")" ArrowPointAtCenter="true">
                                        <Button Icon="edit" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnEditClick(model.Id)"></Button>
                                    </Tooltip>
                                </SpaceItem>
                            </ResourceAuthorize>

                            <ResourceAuthorize ResourceKey="system_manager_function_delete">
                                <SpaceItem>
                                    <Tooltip Title="@("删除")" ArrowPointAtCenter="true">
                                        <Button Icon="delete" Type="@ButtonType.Primary" Danger OnClick="()=>OnDeleteClick(model.Id)"></Button>
                                    </Tooltip>
                                </SpaceItem>
                            </ResourceAuthorize>
                        </Space>
                    </ActionColumn>
                </RowTemplate>
            </Table>
        </ChildContent>
    </PageContainer>
</div>